<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java"  pageEncoding="UTF-8" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>宠物信息修改页面</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <link href="${pageContext.request.contextPath}/static/css/css.css" rel="stylesheet" type="text/css">

    <style type="text/css">
        #content {
            position: relative;
            top: 3px;
            width: 80%;
            height: 380px;
            margin: auto;
            overflow: hidden;
            z-index: 2;
        }

        .tab1 {
            position: relative;
            top: 60px;
            font-size: 24px;
        }

        #in1, #in2, #in3, #in4 ,#in6{
            width: 250px;
            height: 30px;
            font-size: 24px;
        }
        .sid{
            width: 250px;
        }

    </style>
    <script type="text/javascript">
        function checkId() {
            if (document.getElementById("in1").value == "") {
                alert("请输入宠物名称！");
                return false;
            } else {
                return true;
            }
        }
    </script>
</head>
<body>
<!-- include top -->
<jsp:include page="${pageContext.request.contextPath}/top.jsp" flush="true"/>
<center>
    <div id="content">
        <c:if test="${msg!=null}">
            <span style="color: red">${msg}</span>
        </c:if>
        <form action="${pageContext.request.contextPath}/pet/updatePet" method="post" onsubmit="return checkId()">
            <table border="0" cellpadding="0" cellspacing="2" class="tab1">
                <tr align="center">
                    <td>宠物新名称&nbsp;</td>
                    <td><input type="text" name="name" id="in1" value="${pet.name}">
                    </td>
                </tr>
                <tr align="center">
                    <td>宠物新类型&nbsp;</td>
                    <td>
                        <select name="typeName" class="sid">
                            <c:forEach items="${petTypes}" var="type">
                                <c:if test="${type.name.equals(pet.typeName)}">
                                    <option selected value="${type.name}">${type.name}</option>
                                </c:if>
                                <c:if test="${!type.name.equals(pet.typeName)}">
                                    <option value="${type.name}">${type.name}</option>
                                </c:if>
                            </c:forEach>
                        </select>
                    </td>
                </tr>
                <tr align="center">
                    <td>新录入日期&nbsp;</td>
                    <td>
                        <input type="text" readonly id="in2" value="${petBirthDate}"/>
                    </td>
                </tr>
                <tr align="center">
                    <td>新主人名称&nbsp;</td>
                    <td>
                        <select name="ownerName" class="sid">
                            <c:forEach items="${allOwners}" var="owner">
                                <c:if test="${owner.name.equals(pet.owners.name)}">
                                    <option selected value="${owner.name}">${owner.name}</option>
                                </c:if>
                                <c:if test="${!owner.name.equals(pet.owners.name)}">
                                    <option value="${owner.name}">${owner.name}</option>
                                </c:if>
                            </c:forEach>
                        </select>
                    </td>
                </tr>
                <tr align="center">
                    <td colspan="2">
                        <input type="hidden" name="id" value="${pet.id}">
                        <input class="btn btn-default" type="submit" value="修改" />
                        <a class="btn btn-default"
                           href="${pageContext.request.contextPath}/pet/toUpdatePet?name=${pet.name}"
                           role="button">放弃</a>
                    </td>
                </tr>
            </table>
        </form>
    </div>
</center>
<!-- include footer -->
<jsp:include page="${pageContext.request.contextPath}/footer.jsp" flush="true"/>
</body>
</html>
